home *** CD-ROM | disk | FTP | other *** search
/ Basic Instinct 2 Press Kit / Basic Instinct 2 Press Kit.iso / mac / QuickTime704.pkg / Contents / Resources / postflight < prev    next >
Encoding:
Text File  |  2005-09-23  |  3.6 KB  |  163 lines

  1. #!/usr/bin/perl
  2.  
  3. my $SYSVERS = "$ARGV[3]"."/System/Library/CoreServices/SystemVersion.plist";
  4. ##################
  5.  
  6. sub CheckVersion
  7. {
  8.     my $path            = $_[0];
  9.     my $version         = $_[1];
  10.     my $keyName         = $_[2];
  11.     my $operator        = $_[3];
  12.  
  13.     if (! -e $path) {
  14.         return 0;
  15.     }
  16.  
  17.     if (!$operator) {
  18.         $operator = "==";
  19.     }
  20.  
  21.     my $oldSeperator = $/;
  22.     $/ = \0;
  23.  
  24.     open( PLIST, "$path") || do {
  25.         return 0;
  26.     };
  27.  
  28.     $plistData = <PLIST>;
  29.     $plistData =~ /<dict>(.*?)<\/dict>/gis;
  30.  
  31.     @items = split(/<key>/, $plistData);
  32.  
  33.     shift @items;
  34.     foreach $item (@items) {
  35.         $item =~ /(.*?)<\/key>.*?<string>(.*?)<\/string>/gis;
  36.         $versiondata{ $1 } = $2;
  37.     }
  38.  
  39.     close(PLIST);
  40.  
  41.     $/ = $oldSeperator;
  42.  
  43.     @theVersionArray = split(/\./, $versiondata{$keyName});
  44.     for ($i = 0; $i < 3; $i++) {
  45.         if(!$theVersionArray[$i]) {
  46.             $theVersionArray[$i] = '0';
  47.         }
  48.     }
  49.  
  50.     @versionArray = split(/\./, $version);
  51.     
  52.     my $actualVersion;
  53.  
  54.     for ($i = 0; $i < 3; $i++) {
  55.         if (($theVersionArray[$i] != $versionArray[$i]) or ($i == 2)) {
  56.  
  57.             $actualVersion = $theVersionArray[$i];
  58.             $version = $versionArray[$i];
  59.  
  60.             last;
  61.         }
  62.     }
  63.  
  64.     my $expression = '$actualVersion ' . $operator . ' $version';
  65.     if( eval ($expression) )
  66.     {
  67.         return 1;
  68.     }
  69.     else
  70.     {
  71.         return 0;
  72.     }
  73.  
  74. }
  75.  
  76. #######################################
  77.  
  78. my $runnerPID = getppid();
  79. my $installerPID = "";
  80. my $uid = "";
  81. my $uname = "";
  82.  
  83. open( PSOUT, "/bin/ps -axww -o pid,ppid -p $runnerPID |" );
  84. while( <PSOUT> ) {
  85.     my @fields = split '\s+', $_;
  86.     if ("$fields[1]" eq "$runnerPID") {
  87.         $installerPID = $fields[2];
  88.     }
  89. }
  90. close( PSOUT );
  91.  
  92. if ("$installerPID" ne "") {
  93.     open( PSOUT, "/bin/ps -axww -o pid,ruid -p $installerPID |" );
  94.     while( <PSOUT> ) {
  95.         my @fields = split '\s+', $_;
  96.         if ("$fields[1]" eq "$installerPID") {
  97.             $uid = $fields[2];
  98.         }
  99.     }
  100.     close( PSOUT );
  101. }
  102.  
  103. if ("$uid" ne "") {
  104.     open( PSOUTA, "/usr/bin/id -p $uid |" );
  105.     while( <PSOUTA> ) {
  106.         my @fields = split '\s+', $_;
  107.         if ("$fields[0]" eq "uid") {
  108.             $uname = $fields[1];
  109.         }
  110.     }
  111.     close( PSOUTA );
  112. }
  113.  
  114. ###################################################################
  115.  
  116. # Remove old unneeded quicktime pieces
  117. my $CLEANUP_SCRIPT = "$ARGV[0]" . "/Contents/Resources/cleancruft";
  118. $cmd = "\"$CLEANUP_SCRIPT\" \"$ARGV[0]\" \"$ARGV[1]\" \"$ARGV[2]\" \"$ARGV[3]\"";
  119. system( "$cmd" );
  120.  
  121. ########    
  122. # Stuff the installation info into the preferences for QT Updates
  123. my $INSTALL_INFO= "$ARGV[0]" . "/Contents/Resources/installinfo";
  124. my $cmd = "\"$INSTALL_INFO\" -postinstall -volume \"$ARGV[2]\" -type full";
  125. #print STDOUT "INSTALL_INFO: $cmd\n";
  126. system( "$cmd" );
  127.  
  128. ########
  129.  
  130. # Configure the browser mime types based on the installed QuickTime
  131. my $CONFIGURE_MIME_TYPES= "$ARGV[0]" . "/Contents/Resources/ConfigureMimeTypes";
  132. my $cmd = "\"$CONFIGURE_MIME_TYPES\" -rescan -verbose";
  133. if ("$uname" ne "") {
  134.     $cmd = "sudo -u $uname \"$CONFIGURE_MIME_TYPES\" -rescan -verbose";
  135. }
  136. #print STDOUT "CONFIGURE_MIME_TYPES: $cmd\n";
  137. system( "$cmd" );
  138.  
  139. ########
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.     
  148. ###########
  149.  
  150.  
  151. #if it is panther than remove the Tiger files.
  152. my $Delete = "$ARGV[0]" . "/Contents/Resources/deleteomatic";
  153. my $PANTHER_DELETED_FILES="$ARGV[0]" . "/Contents/Resources/panthercleanup-list";
  154. if(CheckVersion( "$SYSVERS", "10.4", "ProductVersion", "<" )) {
  155.     system ("$Delete \"$ARGV[2]\" \"$PANTHER_DELETED_FILES\""); 
  156. }
  157.  
  158. ####REMOVE AFTER SEED#######
  159.  
  160. #my $CLEAN_SCRIPT = "$ARGV[0]" . "/Contents/Resources/cleanup";
  161. #$cmd = "\"$CLEAN_SCRIPT\" \"$ARGV[0]\" \"$ARGV[1]\" \"$ARGV[2]\" \"$ARGV[3]\"";
  162. #system( "$cmd" );
  163.